package com.example.springboottest.runtime;

import java.io.IOException;

/**
 * Runtime 还有一个功能 它可以直接单独启动 个进程来运行操作系统的命令
 */
public class RunTimeTest {
    public static void main(String[] args) {
        Runtime rt = Runtime.getRuntime();
        System.out.println("处理器数量: " + rt.availableProcessors());
        System.out.println("空闲内存数: " + rt.freeMemory() / (1024 * 1024));
        System.out.println("总内存数:" + rt.totalMemory() / (1024 * 1024));
        System.out.println("可用最大内存数:" + rt.maxMemory() / (1024 * 1024));
        //运行程序
        try {
            Process dateProcess =rt.exec("date");
            System.out.println(dateProcess.getOutputStream().toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
